package com.yy.jhl.ui.user.presenter;

import com.yy.jhl.api.Api;
import com.yy.jhl.api.RxSubscriber;
import com.yy.jhl.ui.user.contract.BindPhoneContract;
import com.yy.jhl.ui.user.contract.FindPwdContract;

import okhttp3.FormBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;

/**
 * Created by Ellis.Li on 2017/8/30.
 */

public class BindPhonePresenter extends BindPhoneContract.Presenter {

    @Override
    public void bindPhone(String type, String phone,String code) {
        RequestBody requestBody = new FormBody.Builder()
                .add("type", type)
                .add("phone", phone)
                .add("code", code)
                .build();
        mRxManage.addSubscription(Api.getDefault().bindPhone(requestBody), new RxSubscriber<ResponseBody>(mContext, true) {
            @Override
            protected void _onNext(String result) {
                mView.bindSuccess();
            }

            @Override
            protected void _onError(String message) {
                mView.bindFail();
            }
        });
    }
}
